<?php
namespace Admin\Model;
use Think\Model;
class CatModel extends Model{
	public function getTree($pid=0,$lv=0){
		$res = M('Cat')->select();
		$t=array();
		foreach($res as $k=>$v){
			if($v['pid']==$pid){
				$v['lv'] = $lv;
				$t[]=$v;
				// echo "<pre>";
				// print_r($t);
				$t = array_merge($t,$this->getTree($v['cat_id'],$lv+1));
			}

		}
		return $t;
	}
}
?>